@echo off
setlocal

:: 设置 Redis CLI 的目录
set CLI_DIR=master

:START
:: 用户输入端口号
set /p PORT="Enter the port number to connect (e.g., 6379, 6380, 6381, 26379, 26380, 26381) or type 'exit' to quit: "

:: 检查用户是否输入了 'exit'
if "%PORT%"=="exit" (
    echo Exiting...
    goto :EOF
)

:: 检查端口号是否为空
if "%PORT%"=="" (
    echo Port number cannot be empty. Please try again.
    goto START
)

:: 启动 Redis CLI 并连接到指定的端口号
echo Starting Redis CLI on port %PORT%...
start "" "%CLI_DIR%\redis-cli.exe" -p %PORT%

:: 循环回到开始
goto START

endlocal
pause
